home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / basic / buffdemo.zip / BUFFLOAD.SUB < prev    next >
Text File  |  1986-05-12  |  2KB  |  35 lines

  1. 1000 'LISTING 1 - by Jim Pottkotter
  2. 1010 '
  3. 1020 'BUFFLOAD.SUB clears and optionally loads the keyboard buffer
  4. 1030 '
  5. 1040 '=====>  Load Keyboard Buffer
  6. 1050 '
  7. 1060 '----  If BUFF.1$ and BUFF.2$ both contain a string,
  8. 1070 '----  BUFF.1$ overrides BUFF.2$.
  9. 1080 '
  10. 1090 POKE 1050, PEEK(1052)                      'Clear the buffer
  11. 1100 DEF SEG = 0                                'Set segment to 0
  12. 1110 WHILE BUFF.1$ <> ""                        'Case 1 - normal codes
  13. 1120   POKE 1050, 30                            'Address of 1st byte in buffer
  14. 1130   BUFF.LEN% = LEN(LEFT$(BUFF.1$,15))       'Get truncated string size
  15. 1140   POKE 1052, 30 + 2 * BUFF.LEN%            'Addr of 1st byte after buffer
  16. 1150   FOR BUFF.LOOP% = 1 TO BUFF.LEN%          'Loop BUFF.LEN% times
  17. 1160     POKE 1052 + 2 * BUFF.LOOP%, ASC(MID$(BUFF.1$,BUFF.LOOP%,1))    'ASCII
  18. 1170   NEXT                                     'End loop
  19. 1180   BUFF.2$ = ""                             'Prevent case 2
  20. 1190   BUFF.1$ = ""                             'Set exit condition
  21. 1200 WEND                                       'End case 1
  22. 1210 '
  23. 1220 WHILE BUFF.2$ <> ""                        'Case 2 - extended codes
  24. 1230   POKE 1050, 30                            'Address of 1st byte in buffer
  25. 1240   BUFF.LEN% = LEN(LEFT$(BUFF.2$,30))       'Limit is 30 characters
  26. 1250   BUFF.LEN% = (BUFF.LEN% \ 2) * 2          'Force even # of bytes
  27. 1260   POKE 1052, 30 + BUFF.LEN%                'Addr of 1st byte after buffer
  28. 1270   FOR BUFF.LOOP% = 1 TO BUFF.LEN%          'Loop BUFF.LEN% times
  29. 1280     POKE 1053 + BUFF.LOOP%, ASC(MID$(BUFF.2$,BUFF.LOOP%,1))        'ASCII
  30. 1290   NEXT                                     'End loop
  31. 1300   BUFF.2$ = ""                             'Set exit condition
  32. 1310 WEND                                       'End case 2
  33. 1320 '
  34. 1330 RETURN
  35.